﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;
using Microsoft.WindowsAPICodePack.Shell;
namespace NASM_Develop_IDE
{
    public partial class IDEPreferencesData : GlassForm
    {
        
        private Solution _solution;
        private string _output;

        public IDEPreferencesData(Solution solution)
        {
            if (solution == null) throw new ArgumentNullException(nameof(solution));

            _solution = solution;

            InitializeComponent();
            TextBoxHighlighter.Highlight(binaryOutput, "Enter Output Name (e.g. google.COM)");

            AeroGlassCompositionChanged += new EventHandler<AeroGlassCompositionChangedEventArgs>(BuildDialog_AeroGlassCompositionChanged);
            if (AeroGlassCompositionEnabled)
            {
                ExcludeControlFromAeroGlass(panel);
            }
            else
            {
                BackColor = Color.Aqua;
            }
            
        }


        void BuildDialog_AeroGlassCompositionChanged(object sender, AeroGlassCompositionChangedEventArgs e)
        {
            if (e.GlassAvailable)
            {
                
                ExcludeControlFromAeroGlass(panel);
                Invalidate();
            }
            else
            {

                BackColor = Color.Aqua;
            }
        }

        public string Output
        {
            get
            {
                return _output;
            }
        }

        private void buildButton_Click(object sender, EventArgs e)
        {
            NASMBuilder.Clean(_solution.AbsolutePathOfBinFolder);
            _solution.NameOfOutputBinary = binaryOutput.Text;
            string sources = string.Join(" ", _solution.AbsolutePathOfSources);
            
            _output = NASMBuilder.Compile($"-f bin \"{sources}\" -o \"{Path.Combine(_solution.AbsolutePathOfBinFolder, binaryOutput.Text)}\"");
        }
    }
}
